package com.xbb.mapper;

import com.xbb.entity.Module;
import com.xbb.entity.Rolemodules;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Mr xie
 * @since 2020-05-20
 */
public interface RolemodulesMapper extends BaseMapper<Rolemodules> {

    //显示所有模块，并且标识出当前角色拥有的模块--树形
    @Select("select module_id from rolemodules where role_id=#{roleId}")
    public List<Integer> getModuleTreeByRoleId(Integer roleId);

    //根据指定用户id获取用户拥有的模块集合---树形
    @Select("select * from module where id in("+
            "select module_id from rolemodules where role_id in("+
            "select role_id from userroles where user_id=#{uid}))")
    public List<Module> getModuleTreeByUserId(Integer uid);
}
